<?php

/**
 * Created by PhpStorm.
 * User: feng
 * Date: 2016/12/26
 * Time: 下午9:06
 */
class Lyw_permission_model extends CI_Model
{
    public function readProofreadPermission($is_proofreaded, $original_user_id, $translation_user_id, $proofread_user_id)
    {
        switch ($_SESSION['user_type']) {
            case 1 :
                /*校对完成且当前用户为翻译员*/
                if ($is_proofreaded != 2 || $translation_user_id != $_SESSION['user_id']) {
                    exit('illege');
                }
                break;
            case 2:
                /*该任务为当前用户所发布的*/
                if ($original_user_id != $_SESSION['user_id']) {
                    exit('illege');
                }
                break;
            case 3:
                /*该任务已经完成*/
                if ($is_proofreaded != 2) {
                    exit('illege');
                }
                break;
            case 4:
                /*该任务已经完成*/
                if ($is_proofreaded != 2) {
                    exit('illege');
                }
                break;
            default:
                exit('Error : not type select to read proofread permission');
        }
    }

    public function readTranslationPermission($is_translationed, $original_user_id, $translation_user_id)
    {
        switch ($_SESSION['user_type']) {
            case 1 :
                /*当前用户须为该文章翻译员*/
                if ($translation_user_id != $_SESSION['user_id']) {
                    exit('illege');
                }
                break;
            case 2:
                /*必须译员已经翻译结束*/
                if ($is_translationed != 2 || $original_user_id != $_SESSION['user_id']) {
                    exit('illege');
                }
                break;
            case 3:
                /*该任务已经完成*/
                if ($is_translationed != 2) {
                    exit('illege');
                }
                break;
            case 4:
                /*该任务已经完成*/
                if ($is_translationed != 2) {
                    exit('illege');
                }
                break;
            default:
                exit('Error : not type select to read proofread permission');
        }
    }
}